package com.centriole.service.exuser.controller;


import com.centriole.common.utils.PaasResult;
import com.centriole.common.entity.ExRole;
import com.centriole.common.entity.ExUser;
import com.centriole.service.exuser.service.ExUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 功   能： ExUserController  "ex"对外使用的
 * 创建人：陈默晗
 * 时   间：2018年4月11日上午9:18:46
 */
@RestController
@RequestMapping(value = "/user", produces = "application/json; charset=utf-8")
public class ExUserController {

    @Autowired
    ExUserService exUserService;

    @RequestMapping({"/",""})
    public List<ExUser> listAllExUsers() {
        List<ExUser> exUsers = exUserService.listRAllExUsers(null);
        return exUsers;
    }
    /*
    @RequestMapping("/{userId}")
    public PaasResult findExUsersByUserId(@PathVariable("userId") String userId) {
        ExUser exUsers = exUserService.findRByUserId(userId);
        return PaasResult.success(exUsers);
    }
    */
    @RequestMapping("/r")
    public List<ExRole> listAllExRoles() {
        List<ExRole> exRoles = exUserService.listRAllRoles();
        return exRoles;
    }

    @RequestMapping("/p")
    public PaasResult listAllPermission() {
        return PaasResult.success();
    }

    @RequestMapping("/login")
    public PaasResult register(ExUser user, String ip) {
        return  exUserService.login(user, ip);
    }

    @RequestMapping("/logout")
    public boolean loginOut(String accountName) {
        return exUserService.logout(accountName);

    }

}
